﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Core.Dao;
using Core.Entity;
using System.Data;

namespace Core.Business
{
    public class DownloadBus
    {
        private DownloadDao dao;
        public DownloadBus()
        {
            dao = new DownloadDao();
        }

        public bool insert(Download download) {
            return dao.insert(download);
        }

        public bool update(Download download) {
            return dao.update(download);
        }

        public bool delete(int id) {
            return dao.delete(id);
        }

        public bool delete(String ids) {
            return dao.delete(ids);
        }

        public Download get(int id) {
            DataTable dt = dao.get(id);
            Download download = new Download();

            if (dt.Rows.Count > 0)
            {
                download.Id = Convert.ToInt32(dt.Rows[0]["DWN_ID"]);
                download.LanguageId = Convert.ToInt32(dt.Rows[0]["PGL_ID"]);
                download.Name = dt.Rows[0]["DWN_NAME"].ToString();
                download.Desc = dt.Rows[0]["DWN_DESC"].ToString();
                download.Link = dt.Rows[0]["DWN_LINK"].ToString();
            }
            return download;
        }

        public DataTable getAll() {
            DataTable dt = dao.getAll();
            return dt;
        }
    }
}
